<?php

if(!defined('IN_ECS'))				
{
	die('Hacking attempt');
}

error_reporting(E_ALL);

if(__FILE__ == '')
{
	die('Fatal error code:0');
}

define('ROOT_PATH', str_replace('includes/init.php', '', str_replace('\\', '/', __FILE__)));

@ini_set('memory_limit',		'64M');
@ini_set('session.cache_expire', 180);
@ini_set('session.use_trans_sid', 0);
@ini_set('session.use_cookies', 1);
@ini_set('session.auto_start', 0);
@ini_set('display_errors', 1);


if(DIRECTORY_SEPARATOR == '\\')
{
	@ini_set('include_path', '.;' . ROOT_PATH);
}else{
	@ini_set('include_path', '.:' . ROOT_PATH);
}

require(ROOT_PATH . 'data/config.php');
require(ROOT_PATH . 'includes/inc_constant.php');
require(ROOT_PATH . 'includes/cls_ecshop.php');
require(ROOT_PATH . 'includes/lib_base.php');
require(ROOT_PATH . 'includes/lib_main.php');
require(ROOT_PATH . 'includes/lib_time.php');
require(ROOT_PATH . 'includes/lib_common.php');


$ecs = new ECS($db_name,$prefix); 
define('DATA_DIR', $ecs->data_dir());
define('IMAGE_DIR',$ecs->image_dir());

require(ROOT_PATH . 'includes/cls_mysql.php');
$db = new cls_mysql($db_host,$db_user,$db_pass,$db_name);
$db_host = $db_user = $db_pass = $db_name = NULL;

include(ROOT_PATH . 'includes/cls_session.php');
$sess = new cls_session($db,$ecs->table('sessions'),$ecs->table('sessions_data'));

$_CFG = load_config();

define('SESS_ID', $sess->get_session_id());

header('Cache-control:private');
header('Content-type:text/html;charset='.EC_CHARSET);

require(ROOT_PATH . 'includes/cls_template.php');
$smarty = new cls_template;

$smarty->cache_lifetime = $_CFG['cache_time'];
$smarty->template_dir = ROOT_PATH .'themes/'.$_CFG['template'];
$smarty->cache_dir = ROOT_PATH.'temp/caches';
$smarty->compile_dir = ROOT_PATH .'temp/compiled';

$smarty->assign('lang',$_LANG);
$smarty->assign('ecs_charset',EC_CHARSET);

$smarty->assign('ecs_css_path','themes/'.$_CFG['template'].'/main.css');


